package com.ljpz.web.controller;

import com.ljpz.manage.pojo.ItemDesc;
import com.ljpz.web.bean.Item;
import com.ljpz.web.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

/**
 * Created by liujunchen on 2016/12/18.
 */
@RequestMapping("item")
@Controller
public class ItemController {
    @Autowired
    private ItemService  itemService  ;
    @RequestMapping(value = "{itemId}",method = RequestMethod.GET)
    public ModelAndView itemDetail(@PathVariable("itemId")Long itemId ){
        ModelAndView mv = new ModelAndView("item") ;
         Item item =  this.itemService.queryById(itemId)  ;
        //商品描述信息
        ItemDesc  itemDesc=  this.itemService.queryDescById(itemId) ;
        //商品规格参数数据
        String itemParam  =  this.itemService.queryParamByItemId(itemId) ;
        mv.addObject("item",item);
        mv.addObject("itemDesc" , itemDesc )  ;
        mv.addObject("itemParam" , itemParam)  ;
        return  mv ;
    }
}
